import json
import traceback

from django.core.paginator import Paginator
from rest_framework.response import Response
from rest_framework.decorators import APIView
# Create your views here.
from leavemsg import models
from leavemsg.seriallizer import LeaveMsgSeriallizer
from tools.log import logger
from tools.tool import get_json_values, get_ip, get_time_uuid
from faker import Faker

class GetUserInfo(APIView):
    """
    获取随机用户名和id
    """
    def get(self, request):

        li = []
        resp = {"code": -1, "data": li}
        try:

            uid = get_time_uuid()
            fk = Faker(locale='zh_CN')
            name = fk.name()
            user_info = {'id': uid, 'name': name}

            resp = {"code": 1, "data": user_info}

        except Exception:
            print(traceback.format_exc())
            logger.error(traceback.format_exc())
        return Response(resp)




